var SERVERDATE;
var DATEMODEL;
var arrayNo = new Array("01,13,25,37,49", "02,14,26,38", "03,15,27,39", "04,16,28,40", "05,17,29,41", "06,18,30,42", "07,19,31,43", "08,20,32,44", "09,21,33,45", "10,22,34,46", "11,23,35,47", "12,24,36,48");
var arrNo = [{
    begindate: "2014-01-30",
    enddate: "2015-02-18",
    an: "马,蛇,龙,兔,虎,牛,鼠,猪,狗,鸡,猴,羊"
},
{
    begindate: "2015-02-19",
    enddate: "2016-02-07",
    an: "羊,马,蛇,龙,兔,虎,牛,鼠,猪,狗,鸡,猴"
},
{
    begindate: "2016-02-08",
    enddate: "2017-01-27",
    an: "猴,羊,马,蛇,龙,兔,虎,牛,鼠,猪,狗,鸡"
},
{
    begindate: "2017-01-28",
    enddate: "2018-02-15",
    an: "鸡,猴,羊,马,蛇,龙,兔,虎,牛,鼠,猪,狗"
},
{
    begindate: "2018-02-16",
    enddate: "2019-02-04",
    an: "狗,鸡,猴,羊,马,蛇,龙,兔,虎,牛,鼠,猪"
},
{
    begindate: "2019-02-05",
    enddate: "2020-01-24",
    an: "猪,狗,鸡,猴,羊,马,蛇,龙,兔,虎,牛,鼠"
},
{
    begindate: "2020-01-25",
    enddate: "2021-02-11",
    an: "鼠,猪,狗,鸡,猴,羊,马,蛇,龙,兔,虎,牛"
},
{
    begindate: "2021-02-12",
    enddate: "2022-01-31",
    an: "牛,鼠,猪,狗,鸡,猴,羊,马,蛇,龙,兔,虎"
},
{
    begindate: "2022-02-01",
    enddate: "2023-01-21",
    an: "虎,牛,鼠,猪,狗,鸡,猴,羊,马,蛇,龙,兔"
},
{
    begindate: "2023-01-22",
    enddate: "2024-02-09",
    an: "兔,虎,牛,鼠,猪,狗,鸡,猴,羊,马,蛇,龙"
}];
var arrWxNo = [{
    begindate: "2015-02-19",
    enddate: "2016-02-07",
    j: "01,02,15,16,23,24,31,32,45,46",
    m: "05,06,13,14,27,28,35,36,43,44",
    s: "03,04,11,12,19,20,33,34,41,42,49",
    h: "07,08,21,22,29,30,37,38",
    t: "09,10,17,18,25,26,39,40,47,48"
},
{
    begindate: "2016-02-08",
    enddate: "2017-01-27",
    j: "02,03,16,17,24,25,32,33,46,47",
    m: "06,07,14,15,28,29,36,37,44,45",
    s: "04,05,12,13,20,21,34,35,42,43",
    h: "01,08,09,22,23,30,31,38,39",
    t: "10,11,18,19,26,27,40,41,48,49"
},
{
    begindate: "2017-01-28",
    enddate: "2018-02-15",
    j: "03,04,17,18,25,26,33,34,47,48",
    m: "07,08,15,16,29,30,37,38,45,46",
    s: "05,06,13,14,21,22,35,36,43,44",
    h: "01,02,09,10,23,24,31,32,39,40",
    t: "11,12,19,20,27,28,41,42,49"
},
{
    begindate: "2018-02-16",
    enddate: "2019-02-04",
    j: "04,05,18,19,26,27,34,35,48,49",
    m: "01,08,09,16,17,30,31,38,39,46,47",
    s: "06,07,14,15,22,23,36,37,44,45",
    h: "02,03,10,11,24,25,32,33,40,41",
    t: "12,13,20,21,28,29,42,43"
},
{
    begindate: "2019-02-05",
    enddate: "2020-01-24",
    j: "05,06,19,20,27,28,35,36,49",
    m: "01,02,09,10,17,18,31,32,39,40,47,48",
    s: "07,08,15,16,23,24,37,38,45,46",
    h: "03,04,11,12,25,26,33,34,41,42",
    t: "13,14,21,22,29,30,43,44"
},
{
    begindate: "2020-01-25",
    enddate: "2021-02-11",
    j: "06,07,20,21,28,29,36,37",
    m: "02,03,10,11,18,19,32,33,40,41,48,49",
    s: "08,09,16,17,24,25,38,39,46,47",
    h: "04,05,12,13,26,27,34,35,42,43",
    t: "01,14,15,22,23,30,31,44,45"
},
{
    begindate: "2021-02-12",
    enddate: "2022-01-31",
    j: "07,08,21,22,29,30,37,38",
    m: "03,04,11,12,19,20,33,34,41,42,49",
    s: "09,10,17,18,25,26,39,40,47,48",
    h: "05,06,13,14,27,28,35,36,43,44",
    t: "01,02,15,16,23,24,31,32,45,46"
},
{
    begindate: "2022-02-01",
    enddate: "2023-01-21",
    j: "01,08,09,22,23,30,31,38,39",
    m: "04,05,12,13,20,21,34,35,42,43",
    s: "10,11,18,19,26,27,40,41,48,49",
    h: "06,07,14,15,28,29,36,37,44,45",
    t: "02,03,16,17,24,25,32,33,46,47"
},
{
    begindate: "2023-01-22",
    enddate: "2024-02-09",
    j: "01,02,09,10,23,24,31,32,39,40",
    m: "05,06,13,14,21,22,35,36,43,44",
    s: "11,12,19,20,27,28,41,42,49",
    h: "07,08,15,16,29,30,37,38,45,46",
    t: "03,04,17,18,25,26,33,34,47,48"
}];
var arrRGB = {
    r: "01,02,07,08,12,13,18,19,23,24,29,30,34,35,40,45,46",
    g: "05,06,11,16,17,21,22,27,28,32,33,38,39,43,44,49",
    b: "03,04,09,10,14,15,20,25,26,31,36,37,41,42,47,48"
};
var arrTail = new Array("10,20,30,40", "01,11,21,31,41", "02,12,22,32,42", "03,13,23,33,43", "04,14,24,34,44", "05,15,25,35,45", "06,16,26,36,46", "07,17,27,37,47", "08,18,28,38,48", "09,19,29,39,49");
function getYearAnimal(d) {
    var c = "";
    for (var a = 0; a < arrNo.length; a++) {
        var b = arrNo[a];
        if (d >= b.begindate && d <= b.enddate) {
            c = b.an;
            break
        }
    }
    return c
}
function getZodiacToNo(f, e) {
    var c = "";
    var a = getYearAnimal(e);
    var d = a.split(",");
    for (var b = 0; b < d.length; b++) {
        if (d[b] == f) {
            c = arrayNo[b];
            break
        }
    }
    return c
}
var hk6_an_num = {
    1: "鼠",
    2: "牛",
    3: "虎",
    4: "兔",
    5: "龙",
    6: "蛇",
    7: "马",
    8: "羊",
    9: "猴",
    10: "鸡",
    11: "狗",
    12: "猪"
};
var hk6_color = {
    red: [1, 2, 7, 8, 12, 13, 18, 19, 23, 24, 29, 30, 34, 35, 40, 45, 46],
    blue: [3, 4, 9, 10, 14, 15, 20, 25, 26, 31, 36, 37, 41, 42, 47, 48],
    green: [5, 6, 11, 16, 17, 21, 22, 27, 28, 32, 33, 38, 39, 43, 44, 49]
};
var hk6_lmx = {
    jq: [1, 6, 7, 9, 10, 11],
    ys: [0, 3, 2, 4, 5, 8],
    tx: [3, 4, 1, 11, 8, 6],
    dx: [0, 2, 5, 7, 10, 9],
    qx: [0, 1, 2, 3, 4, 5],
    hx: [6, 7, 8, 9, 10, 11]
};
$(function() {
    $(".quick_sec_table td").each(function() {
        var a = $(this);
        a.hover(function() {
            a.addClass("hover")
        },
        function() {
            a.removeClass("hover")
        })
    });
    SERVERDATE = (new Date()).format("yyyy-MM-dd");
    intervalTimer();
    $(".quick_sec_table tr td").click(function() {
        var f = PeriodPanel.period;
        if (!f || f.status != 1) {
            parent.showMsg("后台未开盘");
            return
        }
        var e = $(this).attr("data");
        var c = e.split("-");
        if (c[0] == "sple") {
            sec_simple(c[1]);
            if (c[1] == "clear") {
                $(".quick_sec_table td").removeClass("on")
            } else {
                if (c[1] == "all") {
                    $(".quick_sec_table").find("[data*='tm']").addClass("on")
                } else {
                    if (c[1] == "fx") {
                        if (c[2] == "num") {
                            $(".quick_sec_table").find("[data*='tm']").toggleClass("on")
                        }
                    }
                }
            }
        } else {
            $(this).toggleClass("on");
            if ($(this).hasClass("on")) {
                oper_sel(c)
            } else {
                _REMOVE = true;
                oper_sel(c);
                _REMOVE = false;
                $(".quick_sec_table td.on").each(function() {
                    oper_sel($(this).attr("data").split("-"))
                })
            }
        }
        var b = $("#bet_panel th.selected").length;
        var a = $("#betcount").text(b);
        if (b == 0) {
            a.parent().hide()
        } else {
            a.parent().show()
        }
    })
});
var oper_sel = function(a) {
    if (a[0] == "col") {
        sec_col(a[1], a[2])
    } else {
        if (a[0] == "sple") {
            sec_simple(a[1])
        } else {
            if (a[0] == "an") {
                sec_animal(a[1])
            } else {
                if (a[0] == "tm") {
                    oper_class(a[1])
                } else {
                    if (a[0] == "lm") {
                        checkLmx(a)
                    } else {
                        if (a[0] == "lmds") {
                            setLmds(a)
                        } else {
                            if (a[0] == "lmqs") {
                                checkLmqs(a[1])
                            }
                        }
                    }
                }
            }
        }
    }
};
var _REMOVE = false;
var oper_class = function(b) {
    var c = $("." + HK6type + "_" + (b >= 10 ? b: "0" + b));
    if (_REMOVE) {
        c.removeClass("selected")
    } else {
        c.addClass("selected")
    }
    if (c.hasClass("selected")) {
        var a = $("label.quickAmount input").val();
        c.find("input").val(a)
    } else {
        c.find("input").val("")
    }
};
var oper_class_lmx = function(b) {
    var c = $("." + HK6type + "_" + b);
    if (_REMOVE) {
        c.removeClass("selected")
    } else {
        c.addClass("selected")
    }
    if (c.hasClass("selected")) {
        var a = $("label.quickAmount input").val();
        c.find("input").val(a)
    } else {
        c.find("input").val("")
    }
};
var oper_class_lmqs = function(a) {
    if (_REMOVE) {
        if ($("." + HK6type + "_" + a + " input:checkbox").prop("checked")) {
            $("." + HK6type + "_" + a + " input:checkbox").click()
        }
    } else {
        if (!$("." + HK6type + "_" + a + " input:checkbox").prop("checked")) {
            $("." + HK6type + "_" + a + " input:checkbox").click()
        }
    }
};
var oper_class_clear = function(a) {
    var b = $("." + HK6type + "_" + (a >= 10 ? a: "0" + a));
    b.removeClass("selected");
    b.find("input").val("")
};
var sec_col = function(a, b) {
    var c = function(f) {
        for (var e = 0; e < f.length; e++) {
            var d = f[e];
            if (b == "") {
                oper_class(d)
            } else {
                if (b == "dan" && d % 2 == 1) {
                    oper_class(d)
                } else {
                    if (b == "shuang" && d % 2 == 0) {
                        oper_class(d)
                    } else {
                        if (b == "da" && d > 24 && d < 49) {
                            oper_class(d)
                        } else {
                            if (b == "xiao" && d <= 24) {
                                oper_class(d)
                            }
                        }
                    }
                }
            }
        }
    };
    if (a == "red") {
        c(hk6_color.red)
    } else {
        if (a == "blue") {
            c(hk6_color.blue)
        } else {
            if (a == "green") {
                c(hk6_color.green)
            }
        }
    }
};
var sec_simple = function(b) {
    var a = function() {
        for (var d = 1; d <= 49; d++) {
            var c = ((d >= 10) ? ((d - (d % 10)) / 10 + (d % 10)) : d);
            if (b == "all") {
                oper_class(d)
            } else {
                if (b == "clear") {
                    oper_class_clear(d)
                } else {
                    if (b == "fx") {
                        if ($("." + HK6type + "_" + (d >= 10 ? d: "0" + d)).hasClass("selected")) {
                            oper_class_clear(d)
                        } else {
                            oper_class(d)
                        }
                    } else {
                        if (b == "danM" && d % 2 == 1) {
                            oper_class(d)
                        } else {
                            if (b == "shuangM" && d % 2 == 0) {
                                oper_class(d)
                            } else {
                                if (b == "daM" && d > 24 && d < 49) {
                                    oper_class(d)
                                } else {
                                    if (b == "xiaoM" && d <= 24) {
                                        oper_class(d)
                                    } else {
                                        if (b == "xdan" && d % 2 == 1 && d <= 24) {
                                            oper_class(d)
                                        } else {
                                            if (b == "xshuang" && d % 2 == 0 && d <= 24) {
                                                oper_class(d)
                                            } else {
                                                if (b == "ddan" && d % 2 == 1 && d > 24) {
                                                    oper_class(d)
                                                } else {
                                                    if (b == "dshuang" && d % 2 == 0 && d > 24) {
                                                        oper_class(d)
                                                    } else {
                                                        if (b == "hdan" && c % 2 == 1) {
                                                            oper_class(d)
                                                        } else {
                                                            if (b == "hshuang" && c % 2 == 0) {
                                                                oper_class(d)
                                                            } else {
                                                                if (b == "hda" && c > 6) {
                                                                    oper_class(d)
                                                                } else {
                                                                    if (b == "hxiao" && c <= 6) {
                                                                        oper_class(d)
                                                                    } else {
                                                                        if (b == "tou0" && d < 10) {
                                                                            oper_class(d)
                                                                        } else {
                                                                            if (b == "tou1" && d < 20 && d >= 10) {
                                                                                oper_class(d)
                                                                            } else {
                                                                                if (b == "tou2" && d < 30 && d >= 20) {
                                                                                    oper_class(d)
                                                                                } else {
                                                                                    if (b == "tou3" && d < 40 && d >= 30) {
                                                                                        oper_class(d)
                                                                                    } else {
                                                                                        if (b == "tou4" && d < 50 && d >= 40) {
                                                                                            oper_class(d)
                                                                                        } else {
                                                                                            if (b == "wei0" && d % 10 == 0) {
                                                                                                oper_class(d)
                                                                                            } else {
                                                                                                if (b == "wei1" && d % 10 == 1) {
                                                                                                    oper_class(d)
                                                                                                } else {
                                                                                                    if (b == "wei2" && d % 10 == 2) {
                                                                                                        oper_class(d)
                                                                                                    } else {
                                                                                                        if (b == "wei3" && d % 10 == 3) {
                                                                                                            oper_class(d)
                                                                                                        } else {
                                                                                                            if (b == "wei4" && d % 10 == 4) {
                                                                                                                oper_class(d)
                                                                                                            } else {
                                                                                                                if (b == "wei5" && d % 10 == 5) {
                                                                                                                    oper_class(d)
                                                                                                                } else {
                                                                                                                    if (b == "wei6" && d % 10 == 6) {
                                                                                                                        oper_class(d)
                                                                                                                    } else {
                                                                                                                        if (b == "wei7" && d % 10 == 7) {
                                                                                                                            oper_class(d)
                                                                                                                        } else {
                                                                                                                            if (b == "wei8" && d % 10 == 8) {
                                                                                                                                oper_class(d)
                                                                                                                            } else {
                                                                                                                                if (b == "wei9" && d % 10 == 9) {
                                                                                                                                    oper_class(d)
                                                                                                                                }
                                                                                                                            }
                                                                                                                        }
                                                                                                                    }
                                                                                                                }
                                                                                                            }
                                                                                                        }
                                                                                                    }
                                                                                                }
                                                                                            }
                                                                                        }
                                                                                    }
                                                                                }
                                                                            }
                                                                        }
                                                                    }
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    };
    a()
};
var sec_animal = function(a) {
    var e = hk6_an_num[a];
    var c = getZodiacToNo(e, SERVERDATE);
    var d = c.split(",");
    for (var b = 0; b < d.length; b++) {
        var a = Number(d[b]);
        oper_class(a)
    }
};
function get_animal_by_ball(d) {
    var a = Number(d) % 12 - 1;
    if (a == -1) {
        a = 11
    }
    var c = getYearAnimal(SERVERDATE);
    var b = c.split(",");
    return b[a]
}
var get_animal_by_ball_time = function(e, b) {
    var a = Number(e) % 12 - 1;
    if (a == -1) {
        a = 11
    }
    var d = getYearAnimal(b);
    var c = d.split(",");
    return c[a]
};
function analyzeBall(g, b) {
    var d = "";
    var f = g.split(",");
    var e = 0;
    for (var c = 0; c < f.length; c++) {
        var a = f[c];
        if (b == 1) {
            if (a != 49) {
                d += '<span class="b' + a + '">' + a + "</span>"
            }
        } else {
            d += '<span class="b' + a + '">' + a + "</span>"
        }
    }
    return d
}
function getServerDate(a) {
    var b = new Date(a);
    try {
        return {
            Y: (b.getYear() + 1900),
            M: ((b.getMonth() + 1) < 10 ? ("0" + (b.getMonth() + 1)) : (b.getMonth() + 1)),
            d: b.getDate(),
            H: b.getHours(),
            m: b.getMinutes(),
            s: b.getSeconds()
        }
    } catch(c) {}
    return null
}
var h;
var timeCount = 10;
function intervalTimer() {
    clearInterval(h);
    setZodiacBalls();
    if (timeCount <= 0) {
        timeCount = 10;
        setZodiacBalls()
    } else {
        timeCount--
    }
    h = setInterval(intervalTimer, 10000)
}
function setZodiacBalls() {
    $("#bet_panel tr:not(.head)").each(function() {
        var a = $(this);
        a.children("td").each(function() {
            if ($(this).hasClass("balls")) {
                SERVERDATE = (new Date(PeriodPanel.now())).format("yyyy-MM-dd");
                var f = $(this).attr("id").substr(2);
                if (hk6GameType == "1") {
                    var e = $(".wxball_" + f);
                    var c = e.attr("data");
                    var d = getYearToWxNo(c, SERVERDATE);
                    var b = analyzeBall(d, 0);
                    e.html(b)
                } else {
                    if (hk6GameType == "0") {
                        var e = $(".sxball_" + f);
                        var c = e.attr("data");
                        var d = getZodiacToNo(c, SERVERDATE);
                        var b = analyzeBall(d, 0);
                        e.html(b)
                    } else {
                        if (hk6GameType == "2") {
                            var e = $(".hxball_" + f);
                            var c = e.attr("data");
                            var d = getZodiacToNo(c, SERVERDATE);
                            var b = analyzeBall(d, 1);
                            e.html(b)
                        } else {
                            if (hk6GameType == "3" || hk6GameType == "4") {
                                var e = "";
                                if (hk6GameType == "3") {
                                    e = $(".sbball_" + f)
                                } else {
                                    e = $(".wsball_" + f)
                                }
                                var c = e.attr("data");
                                var d = getRGBorTailToNo(c, hk6GameType);
                                var b = analyzeBall(d, 0);
                                e.html(b)
                            }
                        }
                    }
                }
            }
        })
    })
}
function getYearToWxNo(d, e) {
    var c = "";
    for (var a = 0; a < arrWxNo.length; a++) {
        var b = arrWxNo[a];
        if (e >= b.begindate && e <= b.enddate) {
            switch (d) {
            case "金":
                c = b.j;
                break;
            case "木":
                c = b.m;
                break;
            case "水":
                c = b.s;
                break;
            case "火":
                c = b.h;
                break;
            case "土":
                c = b.t;
                break
            }
            break
        }
    }
    return c
}
function getRGBorTailToNo(b, a) {
    var c = "";
    if (a == "3") {
        switch (b) {
        case "红波":
            c = arrRGB.r;
            break;
        case "蓝波":
            c = arrRGB.b;
            break;
        case "绿波":
            c = arrRGB.g;
            break
        }
    } else {
        if (a == "4") {
            b = b.replace("尾", "");
            c = arrTail[b]
        }
    }
    return c
}
function checkLmx(c) {
    var b = c[1];
    HK6type = c[2];
    var a = c[3];
    switch (b) {
    case "jq":
        setlmx(hk6_lmx.jq, a);
        break;
    case "ys":
        setlmx(hk6_lmx.ys, a);
        break;
    case "tx":
        setlmx(hk6_lmx.tx, a);
        break;
    case "dx":
        setlmx(hk6_lmx.dx, a);
        break;
    case "qx":
        setlmx(hk6_lmx.qx, a);
        break;
    case "hx":
        setlmx(hk6_lmx.hx, a);
        break
    }
}
function setlmx(b, a) {
    for (var d = 0; d < b.length; d++) {
        var c = b[d];
        if (a == "1") {
            oper_class_lmqs(c)
        } else {
            oper_class_lmx(c)
        }
    }
}
function setLmds(d) {
    var c = d[1];
    var e = new Array(d[2], d[3]);
    for (var a = 0; a < e.length; a++) {
        HK6type = e[a];
        for (var b = 0; b < 10; b++) {
            if (c == "dan" && b % 2 != 0) {
                oper_class_lmx(b)
            } else {
                if (c == "shuang" && b % 2 == 0) {
                    oper_class_lmx(b)
                }
            }
        }
    }
}
function checkLmqs(a) {
    switch (a) {
    case "jq":
        setlmqs(hk6_lmx.jq);
        break;
    case "ys":
        setlmqs(hk6_lmx.ys);
        break
    }
}
function setlmqs(b) {
    for (var e = 0; e < b.length; e++) {
        var d = b[e];
        var f = arrayNo[d];
        for (var c = 0; c < f.length; c++) {
            var a = f.split(",");
            oper_class_lmx(a[c])
        }
    }
};